<?php

namespace app\common\model\xilujob;

use think\Cache;
use think\Model;


class CompanyProperties extends Model
{

    // 表名
    protected $name = 'xilujob_company_properties';
    const CACHE_KEY = 'company_properties';

    // 追加属性
    protected $append = [
        'visible_switch_text'
    ];

    
    public function getVisibleSwitchList()
    {
        return ['0' => __('Visible_switch 0'), '1' => __('Visible_switch 1')];
    }


    public function getVisibleSwitchTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['visible_switch']) ? $data['visible_switch'] : '');
        $list = $this->getVisibleSwitchList();
        return isset($list[$value]) ? $list[$value] : '';
    }



    public static function getAll() {
        $cacheKey = self::CACHE_KEY;
        $all = Cache::get($cacheKey);
        if(!$all) {
            $all = static::order('weigh')->select();
            Cache::set($cacheKey, $all, 3600);
        }
        return $all;
    }
}
